﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FbKPI.Facade;
using FbKPI.Model;

namespace FBKPI.Forms
{
    public partial class SubBranchForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
                int ID = Convert.ToInt16(Request.QueryString["ID"]);
                if (ID != 0)
                {
                    SubBranchFacade df = new SubBranchFacade();
                    SubBranch SubBranchs = df.GetSubBranchByID(ID);

                    if (SubBranchs != null)
                    {
                        txt_id.Text = SubBranchs.ID.ToString();
                        hfId.Value = SubBranchs.ID.ToString();
                        txt_code.Text = SubBranchs.Code;
                        txt_orgid.Text = SubBranchs.OrgID;
                        txt_description.Text = SubBranchs.Description;
                        chk_active.Checked = SubBranchs.isActive;
                        txt_location.Text = SubBranchs.Location.Description;
                        txt_locationid.Value = SubBranchs.Location.ID.ToString();
                        txt_classbranch.Text = SubBranchs.ClassBranch;
                        txt_warehouseid.Text = SubBranchs.WarehouseID;
                        txt_phone.Text = SubBranchs.Phone;
                        txt_address.Text = SubBranchs.Address;
                        //txt_lastmodifieddate.Text = SubBranchs.LastModifiedDate == null ? "" : Convert.ToDateTime(SubBranchs.LastModifiedDate).ToShortDateString();
                        //txt_lastmodifiedby.Text = SubBranchs.LastModifiedBy;
                        //txt_createdate.Text = SubBranchs.CreateDate == null ? "" : Convert.ToDateTime(SubBranchs.CreateDate).ToShortDateString();
                        //txt_createby.Text = SubBranchs.CreateBy;
                    }
                }
                else
                {
                    txt_id.Text = "0";
                }

                //if (txt_id.Text == "0") btn_delete.Visible = false;
            }
        }
    }
}